package logica;
import java.sql.*;


public class ConexionBD {

	/*** clase para conectar a la base de datos */
		static String bd="PYD_Desarrollo";
		static String login="root";
		static String passwd="admin";
		static String url="jdbc:mysql://localhost/" + bd;
		
		Connection conn=null;
		public ConexionBD(){
		try{
				Class.forName("com.mysql.jdbc.Driver");
				conn=DriverManager.getConnection(url,login,passwd);
		
			}catch (SQLException e){
				System.out.println(e);
			}catch (ClassNotFoundException e){
				System.out.println(e);
			}
		}	
		
		public ConexionBD(String db){
		try{
				url="jdbc:mysql://localhost/"+db;
				Class.forName("com.mysql.jdbc.Driver");
				conn=DriverManager.getConnection(url,login,passwd);
				
			}catch (SQLException e){
				System.out.println(e);
			}catch (ClassNotFoundException e){
				System.out.println(e);
			}
		}
		
		public Connection getConnection(){
			return conn;
		}
		
		public void desconectar(){
			try {
				conn.close();
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		public Statement createStatement() {
			// TODO Auto-generated method stub
			return null;
		}	
	
}
